// This example shows how to read values of 4 items at once, and display them.
using System;
using System.Diagnostics;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.DataAccess;
namespace DocExamples.DataAccess._EasyDAClient
{
class ReadMultipleItemValues
{
public static void Main1()
{
// Instantiate the client object.
var client = new EasyDAClient();
ValueResult[] valueResults = client.ReadMultipleItemValues("OPCLabs.KitServer.2",
new DAItemDescriptor[]
{
"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"
});
for (int i = 0; i < valueResults.Length; i++)
{
ValueResult valueResult = valueResults[i];
Debug.Assert(!(valueResult is null));
if (valueResult.Succeeded)
Console.WriteLine($"valueResults({i}).Value: {valueResult.Value}");
else
Console.WriteLine($"valueResults({i}) *** Failure: {valueResult.ErrorMessageBrief}");
}
}
// Example output:
//
//valueResults(0).Value: 0.00125125888851588
//valueResults(1).Value: 0.732510924339294
//valueResults(2).Value: -0.993968485238202
//valueResults(3).Value: 0
}
}
# This example shows how to read values of 4 items at once, and display them.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *
# Instantiate the client object.
client = EasyDAClient()
#
valueResultArray = IEasyDAClientExtension.ReadMultipleItemValues(client, [
DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random')),
DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)')),
DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)')),
DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4')),
])
for i, valueResult in enumerate(valueResultArray):
assert valueResult is not None
if valueResult.Succeeded:
print('valueResultArray[', i, '].Value: ', valueResult.Value, sep='')
else:
print('valueResultArray[', i, '] *** Failure: ', valueResult.ErrorMessageBrief, sep='')
# This example shows how to read values of 4 items at once, and display them.
#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess
# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"
# Instantiate the client object.
$client = New-Object EasyDAClient
$valueResults = [IEasyDAClientExtension]::ReadMultipleItemValues($client,
"OPCLabs.KitServer.2", @(
(New-Object DAItemDescriptor("Simulation.Random")),
(New-Object DAItemDescriptor("Trends.Ramp (1 min)")),
(New-Object DAItemDescriptor("Trends.Sine (1 min)")),
(New-Object DAItemDescriptor("Simulation.Register_I4"))
))
for ($i = 0; $i -lt $valueResults.Length; $i++) {
$valueResult = $valueResults[$i]
if ($valueResult.Succeeded) {
Write-Host "valueResults($($i)).Value: $($valueResult.Value)"
}
else {
Write-Host "valueResults($($i)) *** Failure: $($valueResult.ErrorMessageBrief)"
}
}
# Example output:
#
#valueResults(0).Value: 0.00125125888851588
#valueResults(1).Value: 0.732510924339294
#valueResults(2).Value: -0.993968485238202
#valueResults(3).Value: 0